<?php

declare(strict_types=1);

namespace App\Robot\Crontab;

use App\CustHub\Constants\SendRecordStatusConstants;
use App\CustHub\Model\ChSendRecord;
use App\CustHub\Service\ChSendRecordService;
use Hyperf\Di\Annotation\Inject;

/**
 * 发送记录定时任务.
 */
class SendRecordCrontab
{
    #[Inject]
    protected ChSendRecordService $sendRecordService;

    public function execute(): string
    {
//        ChSendRecord::query()
//            ->select(['id','task_id','robot_id','to_id','content','type'])
//            ->where('start_time','<',time())
//            ->where('start_time','<>',0)
//            ->where('status',SendRecordStatusConstants::WAITING)
//            ->chunk(100,function ($item){
//                foreach ($item as $record){
//                    ChSendRecord::query()->where('id',$record['id'])->update(['status'=>SendRecordStatusConstants::SENDING]);
//                    $this->sendRecordService->sendMessage($record['id']);
//                }
//            });
        return 'send record successfully';
    }
}